var cluster=require('cluster');
var numCPUs=require('os').cpus().length;
var http=require('http');


if(cluster.isMaster){
    for(var i=0;i<numCPUs;i++){
        cluster.fork();
    }
    cluster.on('exit', function (worker, code, signal) {
        console.log('Worker '+worker.process.pid + 'died.');
    });
}else{
    http.createServer(function (req, res) {
        res.setHeader('Content-Type','text/plain;charset=utf-8');
        res.end('多核');
    }).listen(3000,function () {
        console.log('ToDoList 3000',new Date());
    });
}